#ifndef UnorderedSet_h
#define UnorderedSet_h
#include "HashTable.hpp"

namespace yfy
{

template <class K, class Hash = bucket_hash::HashFunc<K>>
class unordered_set
{
    struct SetKeyOfT
    {
        const K& operator()(const K& key) const
        {
            return key;
        }
    };
public:
    typedef typename bucket_hash::HashTable<K, K, Hash, SetKeyOfT>::iterator iterator;
    iterator begin()
    {
        return _ht.begin();
    }
    iterator end()
    {
        return _ht.end();
    }
    pair<iterator, bool> insert(const K& key)
    {
        return _ht.insert(key);
    }
private:
    bucket_hash::HashTable<K, K, Hash, SetKeyOfT> _ht;
    
};

void test_unordered_set()
{
    unordered_set<int> s;
    s.insert(3);
    s.insert(4);
    s.insert(5);
    s.insert(3);
    s.insert(1);
    s.insert(2);
    s.insert(6);
    s.insert(16);
    s.insert(46);
    s.insert(26);
    s.insert(36);
    s.insert(1136);


    unordered_set<int>::iterator it = s.begin();
    while (it != s.end())
    {
        cout << *it << " ";
        ++it;
    }
    cout << endl;
}

}
#endif /* UnorderedSet_h */

